﻿using Furion.DatabaseAccessor;
using Furion.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FurStudy.Core
{
    /// <summary>
    /// 自定义仓储接口
    /// </summary>
    /// <typeparam name="TEntity"></typeparam>
    /// <typeparam name="TDbContextLocator"></typeparam>
    public interface IMyRepository<TEntity, TDbContextLocator> : IPrivateRepository<TEntity>
    where TEntity : class, IPrivateEntity, new()
    where TDbContextLocator : class, IDbContextLocator
    {
        /// <summary>
        /// 自定义方法
        /// </summary>
        void MyMethod();
    }

    /// <summary>
    /// 自定义仓储实现类
    /// </summary>
    /// <typeparam name="TEntity"></typeparam>
    /// <typeparam name="TDbContextLocator"></typeparam>
    public class MyRepository<TEntity, TDbContextLocator> : PrivateRepository<TEntity>, IMyRepository<TEntity, TDbContextLocator>, IScoped
    where TEntity : class, IPrivateEntity, new()
    where TDbContextLocator : class, IDbContextLocator
    {
        /// <summary>
        /// 实现基类构造函数
        /// </summary>
        /// <param name="dbContextLocator"></param>
        /// <param name="serviceProvider"></param>
        public MyRepository(Type dbContextLocator, IServiceProvider serviceProvider) : base(dbContextLocator, serviceProvider)
        {
        }

        /// <summary>
        /// 自定义方法
        /// </summary>
        public void MyMethod()
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// 默认数据库自定义仓储接口
        /// </summary>
        /// <typeparam name="TEntity"></typeparam>
        public interface IMyRepository<TEntity> : IMyRepository<TEntity, MasterDbContextLocator>
    where TEntity : class, IPrivateEntity, new()
        {
            
        }

        /// <summary>
        /// 默认数据库自定义仓储实现
        /// </summary>
        /// <typeparam name="TEntity"></typeparam>
        public class MyRepository1<TEntity> : MyRepository<TEntity, MasterDbContextLocator>, IMyRepository<TEntity>, IScoped
    where TEntity : class, IPrivateEntity, new()
        {
            public MyRepository1(Type dbContextLocator, IServiceProvider serviceProvider) : base(dbContextLocator, serviceProvider)
            {
            }
        }
    }
}
